/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.difsonapps.contacttranslator.dto;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * 
 * @author difson
 */
@Entity
@Table(name = "number")
public class NumberDTO  implements Serializable{

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(name = "value")
	private String value;

	@Column(name = "type")
	@Enumerated(EnumType.ORDINAL)
	private NumberTypeEnum type;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idcontact")
	@JsonIgnore
	private ContactDTO contactDTO;

	public NumberDTO() {
		super();
		// TODO Auto-generated constructor stub
	}

	public NumberDTO(String value, NumberTypeEnum type) {
		super();
		this.value = value;
		this.type = type;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public NumberTypeEnum getType() {
		return type;
	}

	public void setType(NumberTypeEnum type) {
		this.type = type;
	}

	public ContactDTO getContactDTO() {
		return contactDTO;
	}

	public void setContactDTO(ContactDTO contactDTO) {
		this.contactDTO = contactDTO;
	}

	@Override
	public boolean equals(Object object) {
		boolean sameSame = false;

		if (object != null && object instanceof NumberDTO) {
			sameSame = this.value.compareTo(((NumberDTO) object).getValue()) == 0;
		}

		return sameSame;
	}

}
